<?php
session_start();

include_once("../../Misc.php");
include_once("../../helpers/CHtml.php");
include_once("../../helpers/CJavascript.php");
include_once("../../helpers/Composer.php");
include_once("../../classCol/classOracleDb.php");
include_once("../models/fetchers.php");

$srcDb = "MST_GL_SUB_ACC";

$GHtml      = new CGHtml;
$GJs        = new CGJavascript;
$Misc       = new Misc;

$CLFetchers = new CLFetchers;

$SourceDb   = new Composer;
$SourceDb   = $SourceDb->init("db");

$SourceDb->add("srcDbGlAcc",             "MST_GL_ACC");
$SourceDb->add("srcDbGlSubAcc",          "MST_GL_SUB_ACC");
$SourceDb->add("srcDbGlSubAccOpt",       "MST_GL_SUB_ACC_OPT");

$Db = new oracleDb;
$Db->init($_SESSION["ORCL"],
          $_SESSION["OPASS"],
          $_SESSION["SID"],
          _NO_COMMENT);

if($Db->connect()){

  /**
   * if isList
   * means get list
   * else
   * means get name
   */
  if($_POST["isList"]){

    $CLFetchers->fetchLstGlSubAcc($Db,
                                  $_POST["glAccCode"],
                                  $SourceDb,
                                  $nGlSubAcc,
                                  $lstGlSubAcc);

    $GHtml->initDropDownContent($lstGlSubAcc["GL_SUB_ACC_NAME"],
                                $_POST["glSubAcc"],
                                $retContent);

    echo  $retContent;
  }else{

    $CLFetchers->fetchGlSubAccCode($Db,
                                   $_POST["glAccCode"],
                                   $_POST["glSubAccName"],
                                   $SourceDb,
                                   $glSubAccCode);

    echo  $glSubAccCode;
  }

  $Db->dc();
}else{

  $Misc->usrDieJs(_DB_CONN_ERROR);
}

?>
